package com.agrm.model.address.pojo;

import com.agrm.model.common.dtos.BaseModel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;

@TableName("china_regions")

@Getter
@Setter
public class ChinaRegions  implements Serializable {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @TableField("code")
    private String code;

    @TableField("name")
    private String name;

    @TableField("full_name")
    private String fullName;

    @TableField("parent_id")
    private Integer parentId;

    @TableField("level")
    private Byte level;

    @TableField("type")
    private String type;

    @TableField("longitude")
    private Double longitude;

    @TableField("latitude")
    private Double latitude;
    //父分类，不进行序列化
    @TableField(exist = false)
    @JsonBackReference
    private ChinaRegions parent;


    //所有子类别
    @TableField(exist = false)
    @JsonManagedReference
    private List<ChinaRegions> children;


    @Override
    public String toString() {
        return "ChinaRegions{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", fullName='" + fullName + '\'' +
                ", parentId=" + parentId +
                ", level=" + level +
                ", type='" + type + '\'' +
                ", longitude=" + longitude +
                ", latitude=" + latitude +
                '}';
    }
}